/**
 * 
 */
package com.ra.wr;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.googlecode.cswish.annotation.Rest;
import com.ra.external.RoomOrderExtService;
import com.ra.landlord.LandlordUser;
import com.ra.landlord.LandlordUserService;

/**
 * 房东对房间的预定/出租确认
 * @author Jebel Qin
 * @date 2015年7月1日
 * @since v1.0
 */

@Service
public class RoomApplyService
{
	@Resource
	private LandlordUserService landlordService;
	
	@Resource
	private RoomOrderExtService orderRoomService;
	
	/**
	 * 查询所有的订单记录。(订单状态: 预订待确认/租房待确认; 订金待支付/租金待支付)
	 * @return
	 */
	//@Rest(type = "search")
	@Rest(simpleServiceName = "anonymity", type = "free")
	public List<RoomTdo> searchRoomOrders()
	{
		LandlordUser landlordUser = landlordService.getLoginUser();
		return orderRoomService.searchOrders(landlordUser.getId());
	}
	
	/**
	 * 订单详情
	 * @param orderId
	 * @return
	 */
	//@Rest(type = "update")
	@Rest(simpleServiceName = "anonymity", type = "free")
	public RoomTdo getOrderDetail(Integer orderId)
	{
		LandlordUser landlordUser = landlordService.getLoginUser();
		return orderRoomService.getOrderDetail(orderId, landlordUser.getId());
	}
	
	/**
	 *  确定订单
	 * @param orderId
	 */
	//@Rest(type = "update")
	@Rest(simpleServiceName = "anonymity", type = "free")
	public Boolean applyConfirm(Integer orderId)
	{
		LandlordUser landlordUser = landlordService.getLoginUser();
		orderRoomService.applyConfirm(orderId, landlordUser.getId());
		return Boolean.TRUE;
	}
	
	/**
	 * 拒绝订单
	 * @param orderId
	 */
	//@Rest(type = "update")
	@Rest(simpleServiceName = "anonymity", type = "free")
	public Boolean applyRefuse(Integer orderId)
	{
		LandlordUser landlordUser = landlordService.getLoginUser();
		orderRoomService.applyRefuse(orderId, landlordUser.getId());
		return Boolean.TRUE;
	}
	
	/**
	 * 拒绝订单至申请状态
	 * @param orderId
	 * @return
	 */
	//@Rest(type = "update")
	@Rest(simpleServiceName = "anonymity", type = "free")
	public Boolean refuseToLastStatus(Integer orderId)
	{
		LandlordUser landlordUser = landlordService.getLoginUser();
		orderRoomService.refuseToLastStatus(orderId, landlordUser.getId());
		return Boolean.TRUE;
	}
	
	/**
	 * 近期出租记录
	 * @return
	 */
	//@Rest(type = "search")
	@Rest(simpleServiceName = "anonymity", type = "free")
	public List<RoomTdo> getHistoryRents()
	{
		LandlordUser landlordUser = landlordService.getLoginUser();
		return orderRoomService.getHistoryRents(landlordUser.getId());
	}
	
	/**
	 * 获取出租详情
	 * @param orderId
	 * @return
	 */
	//@Rest(type = "search")
	@Rest(simpleServiceName = "anonymity", type = "free")
	public RoomTdo getRentDetail(Integer orderId)
	{
		LandlordUser landlordUser = landlordService.getLoginUser();
		return orderRoomService.getRentDetail(orderId, landlordUser.getId());
	}
}
